cmake_minimum_required(VERSION 3.0)

project(PROJECT3_SPLINE)

find_package(PkgConfig REQUIRED)
pkg_check_modules(LAPACKE REQUIRED lapacke)

link_directories("/usr/local/lib")
include_directories("${PROJECT_SOURCE_DIR}/include")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") 

#default compiler
set(CMAKE_C_COMPILER "/usr/bin/gcc") 
set(CMAKE_CXX_COMPILER "/usr/bin/g++") 

add_subdirectory(main)

add_subdirectory(test)

add_subdirectory(doc)

set(EXECUTABLE_OUTPUT_PATH "${PROJECT_SOURCE_DIR}/bin") # 可执行文件输出目录

add_custom_target(run_assignment
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/bin/main
COMMAND ./PROJECT3_ASSIGNMENT
)

add_custom_target(run_test_plot
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/bin/test
COMMAND ./Spline_test_cmake
COMMAND octave spl2.m 
COMMAND octave spl3.m 
COMMAND octave spl4.m 
COMMAND octave spl5.m 
COMMAND octave spl6.m 
COMMAND octave spl7.m 
COMMAND octave spl8.m
COMMAND octave spl9.m 
COMMAND octave spl10.m 
)

add_custom_target(clean_output
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMAND rm -rf bin/test/*.m bin/test/*.png
COMMAND rm -rf output/*.m output/*.png
)
